using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using Crusades.Geometry;
using Crusades.Helpers;

namespace Crusades.Arrows{
  public class BezierArrowSegment{
    public VectorPair FinalVector{ get; private set;}
    private readonly Vector[] controlPoints;
    private int objectID;
    private int objectCounter;

    private int ObjectID {
      get {
        if (objectID == 0) {
          objectID = objectCounter++;
        }
        return objectID;
      }
    }

    public BezierArrowSegment(Vector[] ControlPoints){
      controlPoints = ControlPoints;
      
    }

    public Path RenderTo(PathBuilder builder, double t){
      Bezier bezier = new Bezier(controlPoints);
      Bezier split = bezier.SplitTo(t);
      FinalVector = new VectorPair(split[2],split[3]);
      Path path = builder.AddBezierSegment(split.ControlPoints);
      path.Name = "Bezier" + ObjectID;
      return path;
    }
  }
}